<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${packageName}.${moduleName}.dao.${className}Mapper">
    <resultMap id="${lowClassName}Map" type="${packageName}.${moduleName}.bean.pojo.${className}">
        <#list colList as col>
            <result column="${col.colName}" property="${col.fieldName}" />
        </#list>
    </resultMap>
    <select id="getById" resultMap="${lowClassName}Map">
        SELECT <#list colList as col>${col.colName}<#if colList?size-1!=col_index>,</#if></#list>
        FROM ${tableName} WHERE ${firstCol}=#${'{'}${firstParam}}
    </select>
    <select id="listAll" resultMap="${lowClassName}Map">
        SELECT <#list colList as col>${col.colName}<#if colList?size-1!=col_index>,</#if></#list>
        FROM ${tableName}
    </select>
    <select id="queryListCount" parameterType="java.util.Map" resultType="Integer">
        SELECT COUNT(1) FROM ${tableName}
        <include refid="Base_Where_Clause" />
    </select>
    <select id="listByPage" parameterType="com.finance.framework.lang.Page" resultMap="${lowClassName}Map">
        SELECT <#list colList as col>${col.colName}<#if colList?size-1!=col_index>,</#if></#list>
        FROM ${tableName}
        <include refid="Base_Where_Clause" />
        <choose>
            <when test="sortInfo!=null and sortInfo!='' ">
                order by ${"$\{sortInfo}"},id
            </when>
            <otherwise>
                order by id
            </otherwise>
        </choose>
    </select>
    <sql id="Base_Where_Clause">
        <where>
            <trim prefixOverrides="and">
                <#list colList as col>
                    <if test="params.${col.fieldName} != null and params.${col.fieldName} != ''"> and ${col.colName} = #${'{'}params.${col.fieldName}}</if>
                </#list>
            </trim>
        </where>
    </sql>
</mapper>